// import React from 'react'
import { useEffect } from "react"
import { useLocation, useNavigate } from "react-router-dom"
function Hot_login({children}:any) {
    function Com(){
        let navtion=useNavigate()
        let lonctio=useLocation()
        let token=localStorage.getItem('token')
        let list=['/login','/404']
        let falg=list.includes(lonctio.pathname)
        useEffect(()=>{
            if(!token&&!falg){
                navtion('/login')
            }
        },[token,lonctio])
        return children
    }
  return<Com></Com>
}

export default Hot_login
